package org.boot.easyapi.file.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.boot.easyapi.file.dao.FileInfoRepository;
import org.boot.easyapi.file.entity.FileInfoDO;
import org.boot.easyapi.pojo.web.CommonResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Tag(name = "EasyApi - 文件信息管理")
@RestController
@RequestMapping("/easyapi/file/info")
public class FileInfoController {

    @Resource
    private FileInfoRepository fileInfoRepository;

    @GetMapping("/findList")
    @Operation(summary = "查询当前服务下所有文件信息")
    public CommonResult<List<FileInfoDO>> findList(FileInfoDO fileInfoDO) {
        return CommonResult.success(fileInfoRepository.findList(fileInfoDO));
    }

    @GetMapping("/findById")
    @Operation(summary = "查询当指定文件信息")
    public CommonResult<FileInfoDO> findById(Long id) {
        return CommonResult.success(fileInfoRepository.findById(id));
    }
}
